package com.mycar2w.cloud.web.resolveexception;

import com.mycar2w.cloud.service.exception.UnLoadExceptiopn;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * created time 2017/4/2
 *
 * @author ljc
 * @version V1.0
 */
@ControllerAdvice
public class ResolveException {

    @ExceptionHandler(value = UnLoadExceptiopn.class)
    public ModelAndView unLoadErrorHandler(HttpServletRequest req, UnLoadExceptiopn e) throws Exception {
        ModelAndView mav = new ModelAndView();
        mav.addObject("errorMessage",e.MESSAGE);
        mav.setViewName("login");
        return mav;
    }
    @ExceptionHandler(value = Exception.class)
    public ModelAndView defaultErrorHander(HttpServletRequest req,Exception e) throws Exception{
        e.printStackTrace();
        return new ModelAndView("error");
    }
}
